package com.recharge.controller.callback;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.recharge.domain.TradeFlow;
import com.recharge.domain.TradeOrder;
import com.recharge.mapper.ITradeFlowMapper;
import com.recharge.mapper.ITradeOrderMapper;
import com.recharge.sup.AbsSupChargeService;

@Controller
@RequestMapping("/hfquxun")
public class QuXunHfCallBankController {
	private Logger logger = LoggerFactory.getLogger(getClass());
	

    @Autowired
    private ITradeOrderMapper iTradeOrderMapper;

    @Autowired
    private ITradeFlowMapper iTradeFlowMapper;

	
	@Resource(name = "quXunHfChargeServiceImpl")
    private AbsSupChargeService absSupChargeService;
	
	@RequestMapping("/callback")
    @ResponseBody
	public String quXunHf(@RequestParam("userid")String userid,
						  @RequestParam("orderid")String orderid ,
						  @RequestParam("sporderid")String sporderid ,
						  @RequestParam("merchantsubmittime")String merchantsubmittime ,
						  @RequestParam("resultno")String resultno ,
						  @RequestParam("sign")String sign){
		Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put("userid", userid);
        paramMap.put("orderid", orderid);
        paramMap.put("sporderid", sporderid);
        paramMap.put("merchantsubmittime", merchantsubmittime);
        paramMap.put("resultno", resultno);
        paramMap.put("sign", sign);
        logger.info("orderID:{},收到结果回调,返回信息code:{}",sporderid,resultno);
        
        TradeOrder tradeOrder =iTradeOrderMapper.selectByOrderId(sporderid);
        TradeFlow tradeFlow = iTradeFlowMapper.selectByOrderId((short) 2, sporderid);
        absSupChargeService.response(tradeOrder,tradeFlow,paramMap);
        return "1";
		
	}
}
